﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example03.aspx.cs" Inherits="Chapter36.Example03" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 36-3 用 rect 方法绘制矩形</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <style>
        canvas {
            border: thin solid black;
        }

        body > * {
            float: left;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="500" height="140">Your browser doesn't support the <code>canvas</code> element.</canvas>
    <script>
        var ctx = document.getElementById('canvas').getContext('2d');

        ctx.fillStyle = 'yellow';
        ctx.strokeStyle = 'black';
        ctx.lineWidth = 4;

        ctx.beginPath();
        ctx.moveTo(110, 10);
        ctx.lineTo(110, 100);
        ctx.lineTo(10, 10);
        ctx.closePath();

        ctx.rect(110, 10, 100, 90);
        ctx.rect(110, 100, 130, 30);

        ctx.fill();
        ctx.stroke();
    </script>
</body>
</html>
